package com.cyzy.controller;

import com.cyzy.dto.Result;
import com.cyzy.pojo.CampusOrder;
import com.cyzy.pojo.CourseOrder;
import com.cyzy.service.CourseOrderService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/courseOrder")
public class CourseOrderController {

    @Autowired
    private CourseOrderService courseOrderService;

    @GetMapping("/selectAll")
    public Result selectAll(){

        List<CourseOrder> courseOrders  = courseOrderService.selectAll();
        return Result.ok().data("courseOrders",courseOrders);
    }

    @RequestMapping("/selectByStatus")
    public Result selectByStatus(@Param("orderStatus") String orderStatus){

        List<CourseOrder> courseOrders = courseOrderService.selectByStatus(orderStatus);

        if(courseOrders.size() > 0){
            return Result.ok().data("查询到的数据为：",courseOrders);
        } else {
            return Result.error().message("没有查询到数据");
        }
    }
}
